<?php

class Core_Backend_Component_Design_View_Block_Template_Index extends Core_Backend_Share_View_Grid {

    protected function buildToolbar($toolbar){
    	parent::buildToolbar($toolbar);
    	$group = $toolbar->createGroup();
        $group->addLink($this->getUrl(NULL, 'create'), $this->__('share.button.create'));
    }

    protected function buildGrid($grid) {
        $filter = new Kd_Object($this->getRequest()->getParameter('filter'));
        $grid->setId('template_grid')
                ->setPrimaryKey('id')
                ->setSortField($this->getRequest()->getParameter('sort', 'id'))
                ->setSortDirection($this->getRequest()->getParameter('dir', 'asc'))
                ->setSortUrlFormat($this->getSortUrl());
        $grid->addLabelColumn($this->__('share.label.name'), 'name', '{name}')
                ->setSortField('name');
        $grid->addLabelColumn($this->__('share.label.module'), 'module', '{module_name}')
                ->setSortField('module');
        $grid->addLabelColumn($this->__('design.label.web_theme'), 'website_theme', '{website_theme}')
                ->setSortField('theme');
        $grid->addLabelColumn($this->__('share.label.file_name'), 'filename', '{file_name}');
        $grid->addLabelColumn($this->__('share.label.enable'), 'enabled', '{enabled}')
                ->setSortField('enable')
                ->setWidth(60);
        $grid->addLinkColumn('#', 'edit', $this->getUrl(array('id' => '{id}'), 'edit'), $this->__('share.button.edit'))
                ->setWidth(40)
                ->setAlign('center');
        $grid->setDataSource($this->getList()->toArray());
        parent::buildGrid($grid);
    }

    protected function buildPagination($pagination) {
        parent::buildPagination($pagination);
        $pagination->setUrlFormat($this->getPaginationUrl())
                ->setRecordCount($this->getRecords());
    }
}